home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
2_6.lha
/
2_6
/
2_6.c
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
652b
|
39 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ print the bits of a null character pointer
include <stream.h>
include <limits.h>
include "2_6a.c" /* EXPAND */
include "2_6c.c" /* EXPAND */
oid prbits(char byte)
cout << "0b";
for (unsigned long mask = HIBIT(unsigned char);
mask != 0; mask >>= 1)
if ((byte & mask) != 0)
cout << "1";
else
cout << "0";
nt main(int, char**)
include "2_6b.c" /* EXPAND4 */
for (int i = 0; i < sizeof(char*); i++)
{
cout << "byte " << i << " = ";
prbits(pi.byte[i]);
cout << "\n";
}
return 0;